<template>
  <div class="personal-info-page">
    <el-card shadow="hover" :bordered="true">
      <template #header>
        <div class="card-header">
          <el-icon><User /></el-icon>
          <span>个人信息</span>
        </div>
      </template>
      <el-form :model="form" label-width="120px">
        <el-form-item label="用户名">
          <el-input 
            v-model="form.username" 
            disabled 
          />
        </el-form-item>
        <el-form-item label="真实姓名">
          <el-input 
            v-model="form.realName" 
            placeholder="请输入真实姓名"
          />
        </el-form-item>
        <el-form-item label="联系电话">
          <el-input 
            v-model="form.phone" 
            placeholder="请输入联系电话"
          />
        </el-form-item>
        <el-form-item label="电子邮箱">
          <el-input 
            v-model="form.email" 
            placeholder="请输入电子邮箱"
          />
        </el-form-item>
        <el-form-item>
          <el-button 
            type="primary" 
            @click="handleSave"
          >
            保存修改
          </el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script setup>
import { reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { User } from '@element-plus/icons-vue'

// 模拟从接口获取的用户信息
const form = reactive({
  username: 'admin', // 假设用户名不可修改
  realName: '',
  phone: '',
  email: ''
})

// 保存修改
const handleSave = () => {
  // 这里可对接实际接口，示例仅做模拟
  ElMessage.success('个人信息保存成功！')
  // 可在此处调用接口：api/user/saveInfo(form)
}
</script>

<style scoped>
.personal-info-page {
  padding: 20px;
}
.card-header {
  display: flex;
  align-items: center;
}
.card-header .el-icon {
  margin-right: 5px;
}
</style>